package com.yhcui.monitor.bean;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@ApiModel(description="api通用返回数据")
@Data
public class Result<T> {

    @ApiModelProperty(value = "标识代码,200表示成功，非200表示出错", example = "200")
    private int status;

    @ApiModelProperty(value = "错误提示信息")
    private String message;

    @ApiModelProperty(value = "具体业务数据")
    private T data;


    public static Result success() {
        Result<String> result = new Result<>();
        result.status = 200;
        return result;
    }

    public static <T> Result success(T t) {
        Result<T> result = new Result<>();
        result.status = 200;
        result.data =  t;
        return result;
    }

    public static Result error(String msg) {
        Result<String> result = new Result<>();
        result.status = 400;
        result.message = msg;
        return result;
    }

    public static Result innerError(String t) {
        Result<String> result = new Result<>();
        result.status = 500;
        result.message = t;
        return result;
    }

}
